import models.*;
import java.util.ArrayList;
import java.util.List;
import play.test.*;

import org.hibernate.mapping.Array;
import org.junit.*;
import controllers.Projects;
import controllers.Events;
public class GetProjectAndEventStoriesTasks extends UnitTest{
	
    @Before
    public void setup() {
        Fixtures.deleteAll();
    }
	@Test
	public void GetProjectEventStoriesAndTasks()
	{
		User user1=new User("user1","user1middle","user1last","userName","password","user1@kaza.com","0000000000","someplace","somecity","somecountry","my image").save();
		Project p1=new Project("project1",2,true,"testing project").save();
		Component comp1=new Component("comp1", "component 1", p1).save();
		TaskStatus pending=new TaskStatus("pending",true).save();
		UserStory S1=new UserStory("the Test story1",2.0,"high",comp1,user1,null,null,"done").save();
		TaskType implementation=new TaskType("implementation", true).save();
		Task t1=new Task("second Task", "low", implementation, pending, null, user1,S1).save();
		List<Task> actualtasks=new ArrayList<Task>();
		actualtasks.add(t1);
		Event e1=new Event("event1","description",actualtasks).save();
		p1.events.add(e1);p1.save();
		
		
		
		long id= Long.parseLong(p1.getEntityId().toString());
		List <Task> tasks=Projects.getProjectTasks(id, "pending");
		assertEquals(actualtasks, tasks);
		List<UserStory> actualstories =new ArrayList();
		List<UserStory> stories=Projects.getProjectStories(id, "done");
		assertEquals(actualstories, stories);
	


		actualtasks.add(t1);
		id=Long.parseLong(e1.getEntityId().toString());
		List <Task> Eventtasks=Events.getEventTasks(id, "pending");
		assertEquals(actualtasks, Eventtasks);
		List<UserStory> actualEventstories =new ArrayList();
		actualEventstories.add(S1);
		List<UserStory> Eventstories=Events.getEventStories(id, "done");
		assertEquals(actualEventstories, Eventstories);
	
	}
}
